//
//  ResultVC.swift
//  ImGuider X
//
//  Created by 王鹏宇 on 10/29/18.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class ResultVC: UIViewController,UITableViewDelegate,UITableViewDataSource{


        var resultArray : [Record] = [Record]()
        var tableView : UITableView!
        override func viewDidLoad() {
            super.viewDidLoad()
            
            // Do any additional setup after loading the view.
            
            setup()
            
        }
        
        
        func setup(){
            
            self.navigationController?.navigationBar.isHidden = true
            self.navigationController?.navigationBar.isUserInteractionEnabled = false
            tableView = UITableView(frame: CGRect(x: 0, y:100, width: kScreenWidth, height: kScreenHeight - kNavigationBarHeight - kBottomHeight - 16))
            
            self.view.addSubview(tableView)
            
            self.tableView.delegate = self
            self.tableView.dataSource = self
            
            self.tableView.register(UINib(nibName: "SearchNumCell", bundle: nil), forCellReuseIdentifier: "SearchNumCell")
            
            self.view.backgroundColor = UIColor.clear;
            self.tableView.backgroundColor = UIColor.white
            //        self.automaticallyAdjustsScrollViewInsets = false
            
            
//            if #available(iOS 11.0, *) {
//                tableView.contentInsetAdjustmentBehavior = .never
//            } else {
//                automaticallyAdjustsScrollViewInsets = false
//            }
            
            //        self.toTopSpace.constant = 100
            self.tableView.estimatedRowHeight = 44
            self.tableView.rowHeight = UITableView.automaticDimension
            
        }
    }
    
    
    extension ResultVC{
        
        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            
            return resultArray.count
        }
        
        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            
            let cell = tableView.dequeueReusableCell(withIdentifier: "SearchNumCell") as! SearchNumCell
            var record = Record()
            record = self.resultArray[indexPath.row]
            cell.configData(record: record)
            
            return cell
        }
        
        func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
            
            
        }
}
